import React from "react";
import {Switch, Route, Redirect,} from "react-router-dom";

import Hero from "./hero";
import Skill from "./skill";
import Tool from "./tool";
import NoMatch from "./404";

const routes = [
  {
    path: '/',
    exact: true,
    component: Hero,
  },
  {
    path: '/hero',
    exact: true,
    component: Hero,
  },
  {
    path: '/skill',
    exact: true,
    component: Skill,
  },
  {
    path: '/tool',
    exact: true,
    redirect: '/skill',
    component: Tool,
  },
  {
    path: '*',
    exact: true,
    component: NoMatch,
  },
];

const Router = () => {
  return (
    <Switch>
      {routes.map((route, index) => (
        <Route
          key={index}
          path={route.path}
          exact={route.exact}
          children={route.redirect ? <Redirect to={route.redirect } /> : <route.component/>}
        />
      ))}
    </Switch>
  )
}
export {
  Router,
  routes,
};
